import numpy as np
import pandas as pd
import scanpy as sc
import scrublet as scr
import doubletdetection
import warnings
import matplotlib.pyplot as plt
import seaborn as sns
warnings.filterwarnings('ignore')
import logging
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.logging.print_versions()
sc.settings.set_figure_params(dpi=130)
adata_ann = sc.read_h5ad('./output/wt.ann.h5ad')
adata_raw = sc.read_h5ad('./output/wt.preprocessing.h5ad')
adata_raw.shape
sc.tl.paga(adata_ann, groups='cell_type')
sc.pl.paga(adata_ann, color=['cell_type'], threshold=0.3)
sc.tl.draw_graph(adata_ann, init_pos='paga')
sc.pl.draw_graph(adata_ann, color=['cell_type'])
sc.pl.paga_compare(
adata_ann, threshold=0.3, title='', right_margin=0.2, size=10, edge_width_scale=0.5,
legend_fontsize=0, fontsize=0, frameon=False, edges=True)
sc.pl.paga_compare(
adata_ann, threshold=0.35, title='', right_margin=0.2, size=10, edge_width_scale=0.4,
legend_fontsize=0, fontsize=0, frameon=False, edges=True)
sc.pl.paga(adata_ann,
threshold=0,
solid_edges='connectivities_tree',
dashed_edges='connectivities',
layout='rt_circular',
node_size_scale=0.5,
node_size_power=0.9,
max_edge_width=0.7,
fontsize=3.5)
sc.pl.draw_graph(adata_ann, color=['Itm2a', 'Ccr9', 'Pdcd1', 'Cd27'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Cd28', 'Slamf6', 'Sox4', 'Lef1'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Id3', 'Tox', 'Plac8', 'Zbtb16'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Drosha', 'Ran', 'Tcf7', 'Rorc'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Blk', 'Izumo1r', 'Klrb1c', 'Nkg7'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Cxcr3', 'Gzmb', 'Ifngr1', 'Il17re'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Il1r1', 'Il18r1', 'Aqp3','Ccr2'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Ccr6', 'Klra5', 'Klrc2', 'Klre1'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Tbx21', 'Ccr7'], legend_loc='on data')
cell_bool = []
for x in adata_ann.obs['cell_type']:
cell_bool = cell_bool + [x in ['NKT0','NKT17','NKT2a','NKT2b','NKT1a','NKT1b','NKT1c']]
list_of_cell_names = adata_ann.obs.loc[cell_bool, :].index.tolist()
adata_ann = adata_ann[list_of_cell_names, ]
adata_ann.shape
sc.tl.paga(adata_ann, groups='cell_type')
sc.pl.paga(adata_ann, color=['cell_type'], threshold=0.05)
sc.tl.draw_graph(adata_ann, init_pos='paga')
sc.pl.draw_graph(adata_ann, color=['cell_type'], legend_loc='on data')
sc.pl.paga_compare(
adata_ann, threshold=0.3, title='', right_margin=0.2, size=10, edge_width_scale=0.5,
legend_fontsize=0, fontsize=0, frameon=False, edges=True)
sc.pl.paga_compare(
adata_ann, threshold=0.05, title='', right_margin=0.2, size=10, edge_width_scale=0.5,
legend_fontsize=0, fontsize=0, frameon=False, edges=True)
sc.pl.paga(adata_ann,
threshold=0,
solid_edges='connectivities_tree',
dashed_edges='connectivities',
layout='rt_circular',
node_size_scale=0.5,
node_size_power=0.9,
max_edge_width=0.7,
fontsize=3.5)
sc.pl.draw_graph(adata_ann, color=['Itm2a', 'Ccr9', 'Pdcd1', 'Cd27'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Cd28', 'Slamf6', 'Sox4', 'Lef1'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Id3', 'Tox', 'Plac8', 'Zbtb16'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Drosha', 'Ran', 'Tcf7', 'Rorc'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Blk', 'Izumo1r', 'Klrb1c', 'Nkg7'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Cxcr3', 'Gzmb', 'Ifngr1', 'Il17re'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Il1r1', 'Il18r1', 'Aqp3','Ccr2'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Ccr6', 'Klra5', 'Klrc2', 'Klre1'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Tbx21', 'Ccr7'], legend_loc='on data')
adata_ann = sc.read_h5ad('./output/ko.ann.h5ad')
adata_raw = sc.read_h5ad('./output/ko.preprocessing.h5ad')
adata_raw.shape
cell_bool = []
for x in adata_ann.obs['cell_type']:
cell_bool = cell_bool + [x in ['NKT0','NKT17','NKT2a','NKT2b','NKT1a','NKT1b','NKT1c']]
list_of_cell_names = adata_ann.obs.loc[cell_bool, :].index.tolist()
adata_ann = adata_ann[list_of_cell_names, ]
adata_ann.shape
sc.tl.paga(adata_ann, groups='cell_type')
sc.pl.paga(adata_ann, color=['cell_type'], threshold=0.05)
sc.tl.draw_graph(adata_ann, init_pos='paga')
sc.pl.draw_graph(adata_ann, color=['cell_type'], legend_loc='on data')
sc.pl.paga_compare(
adata_ann, threshold=0.05, title='', right_margin=0.2, size=10, edge_width_scale=0.5,
legend_fontsize=0, fontsize=0, frameon=False, edges=True)
sc.pl.paga_compare(
adata_ann, threshold=0.05, title='', right_margin=0.2, size=10, edge_width_scale=0.5,
legend_fontsize=0, fontsize=0, frameon=False, edges=True)
sc.pl.paga(adata_ann,
threshold=0,
solid_edges='connectivities_tree',
dashed_edges='connectivities',
layout='rt_circular',
node_size_scale=0.5,
node_size_power=0.9,
max_edge_width=0.7,
fontsize=3.5)
sc.pl.draw_graph(adata_ann, color=['Itm2a', 'Ccr9', 'Pdcd1', 'Cd27'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Cd28', 'Slamf6', 'Sox4', 'Lef1'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Id3', 'Tox', 'Plac8', 'Zbtb16'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Drosha', 'Ran', 'Tcf7', 'Rorc'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Blk', 'Izumo1r', 'Klrb1c', 'Nkg7'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Cxcr3', 'Gzmb', 'Ifngr1', 'Il17re'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Il1r1', 'Il18r1', 'Aqp3','Ccr2'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Ccr6', 'Klra5', 'Klrc2', 'Klre1'], legend_loc='on data')
sc.pl.draw_graph(adata_ann, color=['Tbx21', 'Ccr7'], legend_loc='on data')